package com.castrianni.vcs;

import java.util.Comparator;
import java.util.Date;

public class VcsFileRevisionDateComparator implements Comparator<VcsRevisionGraphRevision> {
  public int compare(VcsRevisionGraphRevision r1,VcsRevisionGraphRevision r2)
  {
    int result;
    result = compareDates(r1.getRevisionDate(),r2.getRevisionDate());
    return(result);
  }

  public int compareDates(Date d1,Date d2)
  {
    if((d1 == null) && (d2 == null))
      return(0);
    if((d1 == null))
      return(-1);
    if((d2 == null))
      return(1);
    Long d1L = d1.getTime();
    Long d2L = d2.getTime();
    return(d1L.compareTo(d2L));
  }
}
